package com.amoqi.controller;

import java.util.List;

import com.amoqi.model.User;
import com.jfinal.core.Controller;

public class UserController extends Controller {
	public void index(){
		List<User> users = User.dao.find("select * from user");
		setAttr("users",users);
		render("list.jsp");
	}
	public void form(){
		Integer id = getParaToInt(0);
		if(id!=null && id>0){
			User user = User.dao.findById(id);
			setAttr("user",user);
		}
		render("form.jsp");
	}
	public void delete(){
		User.dao.deleteById(getPara(0));
		redirect("/user");
	}
	public void edit(){
		form();
	}
	public void submit(){
		User user = getModel(User.class,"user");
		user.save();
		redirect("/user");
	}
	public void update(){
		User user = getModel(User.class,"user");
		user.update();
		redirect("/user");
	}
}
